<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <!--<el-form-item label="供应编码" prop="sellNum">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellNum"-->
          <!--placeholder="请输入供应编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="供应编码" prop="sellNum">
        <el-select v-model="queryParams.sellNum" placeholder="渠道类别" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>-->
      <el-form-item label="供应人" prop="sellName">
        <el-input
          v-model="queryParams.sellName"
          placeholder="请输入供应人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应电话" prop="sellTel">
        <el-input
          v-model="queryParams.sellTel"
          placeholder="请输入供应电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应手机" prop="sellPhone">
        <el-input
          v-model="queryParams.sellPhone"
          placeholder="请输入供应手机"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应公司" prop="sellCompany">
        <el-input
          v-model="queryParams.sellCompany"
          placeholder="请输入供应公司"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应地址" prop="sellAddress">
        <el-input
          v-model="queryParams.sellAddress"
          placeholder="请输入供应地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="供应数量" prop="sellAmount">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellAmount"-->
          <!--placeholder="请输入供应数量"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="供应尺寸" prop="sellSize">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellSize"-->
          <!--placeholder="请输入供应尺寸"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <el-form-item label="供应产品详情" prop="sellProduct">
        <el-input
          v-model="queryParams.sellProduct"
          placeholder="请输入供应产品详情"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="供应产品价格" prop="sellProductPrice">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellProductPrice"-->
          <!--placeholder="请输入供应产品价格"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="供应时间" prop="sellTime">-->
        <!--<el-date-picker clearable size="small"-->
          <!--v-model="queryParams.sellTime"-->
          <!--type="date"-->
          <!--value-format="yyyy-MM-dd"-->
          <!--placeholder="选择供应时间">-->
        <!--</el-date-picker>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="省" prop="sellProvince">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellProvince"-->
          <!--placeholder="请输入省"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="省编码" prop="sellProvinceCode">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellProvinceCode"-->
          <!--placeholder="请输入省编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <el-form-item label="市" prop="sellCity">
        <el-input
          v-model="queryParams.sellCity"
          placeholder="请输入市"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="市编码" prop="sellCityCode">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellCityCode"-->
          <!--placeholder="请输入市编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="县" prop="sellCounty">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellCounty"-->
          <!--placeholder="请输入县"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="县编码" prop="sellCountyCode">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellCountyCode"-->
          <!--placeholder="请输入县编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="供应类别" prop="sellType">-->
        <!--<el-select v-model="queryParams.sellType" placeholder="请选择供应类别" clearable size="small">-->
          <!--<el-option label="请选择字典生成" value="" />-->
        <!--</el-select>-->
      <!--</el-form-item>-->
      <!--<el-form-item label="供应类别编码" prop="sellTypeCode">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellTypeCode"-->
          <!--placeholder="请输入供应类别编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
     <!-- <el-form-item label="审核状态" prop="isCheck">
        <el-select v-model="queryParams.isCheck" placeholder="审核状态" clearable size="small">
          <el-option
            v-for="dict in checkStatus"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>-->
      <!--<el-form-item label="供应种类编码" prop="sellClassCode">-->
        <!--<el-input-->
          <!--v-model="queryParams.sellClassCode"-->
          <!--placeholder="请输入供应种类编码"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <el-form-item label="供应标题" prop="sellTitle">
        <el-input
          v-model="queryParams.sellTitle"
          placeholder="请输入供应标题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应发布时间间隔" prop="sellPublishInterval">
        <el-select v-model="queryParams.sellPublishInterval" placeholder="供应发布时间间隔" clearable size="small">
          <el-option
            v-for="dict in intervalOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <!--<el-form-item label="图片路径" prop="picAddress">-->
        <!--<el-input-->
          <!--v-model="queryParams.picAddress"-->
          <!--placeholder="请输入图片路径"-->
          <!--clearable-->
          <!--size="small"-->
          <!--@keyup.enter.native="handleQuery"-->
        <!--/>-->
      <!--</el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <!--<el-button icon="el-icon-refresh" size="mini" @click="gotolink">地图</el-button>-->
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:sell:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:sell:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:sell:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
		  :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['system:sell:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="sellList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!--<el-table-column label="图片路径" align="center" prop="id" />-->
<!--      <el-table-column label="供应编码" align="center" prop="sellNum" :formatter="statusFormat"/>-->
      <el-table-column label="供应人" align="center" prop="sellName" />
      <el-table-column label="审核状态" align="center" prop="isCheck" :formatter="checkFormat" />
      <el-table-column label="供应手机" align="center" prop="sellPhone" />
<!--      <el-table-column label="供应公司" align="center" prop="sellCompany" />-->
      <el-table-column label="供应地址" align="center" prop="sellAddress" />
    <!--  <el-table-column label="供应数量" align="center" prop="sellAmount" />
      <el-table-column label="供应尺寸" align="center" prop="sellSize" />-->
      <el-table-column label="供应产品详情" align="center" prop="remark" />
      <el-table-column label="供应时间" align="center" prop="sellTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sellTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!--<el-table-column label="省" align="center" prop="sellProvince" />-->
      <!--<el-table-column label="省编码" align="center" prop="sellProvinceCode" />-->
      <!--<el-table-column label="市" align="center" prop="sellCity" />-->
      <!--<el-table-column label="市编码" align="center" prop="sellCityCode" />-->
      <!--<el-table-column label="县" align="center" prop="sellCounty" />-->
      <!--<el-table-column label="县编码" align="center" prop="sellCountyCode" />-->
      <!--<el-table-column label="供应类别" align="center" prop="sellType" />-->
      <!--<el-table-column label="供应类别编码" align="center" prop="sellTypeCode" />-->
      <el-table-column label="供应种类" align="center" prop="sellClass" />
      <!--<el-table-column label="供应种类编码" align="center" prop="sellClassCode" />-->
      <el-table-column label="供应标题" align="center" prop="sellTitle" />
      <!--<el-table-column label="供应发布时间间隔" align="center" prop="sellPublishInterval" :formatter="intervalFormat" />-->
      <el-table-column label="发布时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="图片路径" align="center" prop="picAddress" show-overflow-tooltip>
        <template width="90" slot-scope="scope">
         <span v-for="(item,index) in scope.row.picAddress.split(';')" :key="index">
             <el-popover  placement="left" trigger="hover" width="300">
                 <img :src="item" width="100%" />
                 <img
                   slot="reference"
                   :src="item"
                   :alt="item"
                   style="max-height: 70px;max-width: 70px; padding: 5px"
                 />
             </el-popover>
          </span>
        </template>
      </el-table-column>
     <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:sell:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:sell:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-plus"
            @click="handleCheck(scope.row,'1')"
            v-hasPermi="['system:sell:edit']"
          >审核</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-minus"
            @click="handleCheck(scope.row,'2')"
            v-hasPermi="['system:sell:edit']"
          >取消审核</el-button>
        </template>

      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改供应信息对话框 -->
    <el-dialog :title="title" :visible.sync="openCheck" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="审核状态" prop="isCheck">
          <el-select v-model="form.isCheck" placeholder="请选择" >
            <el-option
              v-for="dict in checkStatus"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
            </el-select>
          </el-form-item>
          <el-form-item label="未审核通过原因" prop="feedBack">
            <el-input v-model="form.feedBack" placeholder="请输入未审核通过原因" />
          </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改供应信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="供应类型" prop="sellType">
          <el-select v-model="form.sellNum" placeholder="请选择">
            <el-option
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="供应人" prop="sellName">
          <el-input v-model="form.sellName" placeholder="请输入供应人" />
        </el-form-item>
        <el-form-item label="供应电话" prop="sellTel">
          <el-input v-model="form.sellTel" placeholder="请输入供应电话" />
        </el-form-item>
        <el-form-item label="供应手机" prop="sellPhone">
          <el-input v-model="form.sellPhone" placeholder="请输入供应手机" />
        </el-form-item>
        <el-form-item label="供应公司" prop="sellCompany">
          <el-input v-model="form.sellCompany" placeholder="请输入供应公司" />
        </el-form-item>
        <el-form-item label="供应地址" prop="sellAddress">
          <el-input v-model="form.sellAddress" placeholder="请输入供应地址" />
        </el-form-item>
        <el-form-item label="供应数量" prop="sellAmount">
          <el-input v-model="form.sellAmount" placeholder="请输入供应数量" />
        </el-form-item>
        <el-form-item label="起售数量" prop="sellAmount">
          <el-input v-model="form.sellStartAmount" placeholder="请输入起售数量" />
        </el-form-item>
        <el-form-item label="供应尺寸" prop="sellSize">
          <el-input v-model="form.sellSize" placeholder="请输入供应尺寸" />
        </el-form-item>
        <el-form-item label="供应产品详情" prop="sellProduct">
          <el-input v-model="form.remark" placeholder="请输入供应产品详情" />
        </el-form-item>
        <el-form-item label="供应产品价格" prop="sellProductPrice">
          <el-input v-model="form.sellProductPrice" placeholder="请输入供应产品价格" />
        </el-form-item>
        <el-form-item label="售卖方式" prop="sellMode">
          <el-input v-model="form.sellMode" placeholder="请输入售卖方式" />
        </el-form-item>
        <el-form-item label="产品供应期" prop="sellSupplyTime">
          <el-input v-model="form.sellSupplyTime" placeholder="请输入产品供应期" />
        </el-form-item>
        <el-form-item label="产品包装方式" prop="sellPackMode">
          <el-input v-model="form.sellPackMode" placeholder="请输入包装方式" />
        </el-form-item>
        <el-form-item label="供应时间" prop="sellTime">
          <el-date-picker clearable size="small"
            v-model="form.sellTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择供应时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="省" prop="sellProvince">
          <el-input v-model="form.sellProvince" placeholder="请输入省"  :disabled="true"/>
        </el-form-item>
      <!--  <el-form-item label="省编码" prop="sellProvinceCode">
          <el-input v-model="form.sellProvinceCode" placeholder="请输入省编码" />
        </el-form-item>-->
        <el-form-item label="市" prop="sellCity">
          <el-input v-model="form.sellCity" placeholder="请输入市" :disabled="true"/>
        </el-form-item>
       <!-- <el-form-item label="市编码" prop="sellCityCode">
          <el-input v-model="form.sellCityCode" placeholder="请输入市编码" />
        </el-form-item>-->
        <el-form-item label="县" prop="sellCounty">
          <el-input v-model="form.sellCounty" placeholder="请输入县"  :disabled="true"/>
        </el-form-item>
       <!-- <el-form-item label="县编码" prop="sellCountyCode">
          <el-input v-model="form.sellCountyCode" placeholder="请输入县编码" />
        </el-form-item>-->
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="form.longitude" placeholder="请输入经度"  :disabled="true"/>
        </el-form-item>
        <el-form-item label="纬度" prop="longitude">
          <el-input v-model="form.latitude" placeholder="请输入纬度"  :disabled="true"/>
          <showMapDialog :title="showTitle" v-if="isShowDialog" v-model="isShowDialog" :locationInfo="locationInfo" :onlyShowLocation="true" @return-value="getVal"></showMapDialog>
          <el-button size="mini" type="info"  class="el-icon-map-location"  @click="showMpDialog(form)">显示地图</el-button>
        </el-form-item>
        <el-form-item label="一级分类" prop="buyType">
          <el-select v-model="form.sellTypeCode" clearable @clear="shengdel" placeholder="请选择一级分类" @change="chooseProvince"  >
            <el-option
              v-for="item in level1Data"
              :key="item.code"
              :label="item.name"
              :value="item.name">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="二级分类" prop="buyTypeCode" >
          <el-select v-model="form.sellType" clearable @clear="shidel" placeholder="请选择二级分类" @change="chooseCity"  >
            <el-option
              v-for="item in level2Data"
              :key="item.code"
              :label="item.name"
              :value="item.name">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="三级分类" prop="buyClass">
          <el-select v-model="form.sellClass" clearable @clear="qudel" @change="chooseArea" placeholder="请选择三级分类"  >
            <el-option
              v-for="item in level3Data"
              :key="item.code"
              :label="item.name"
              :value="item.name">
            </el-option>
          </el-select>
        </el-form-item>
       <!-- <el-form-item label="供应类别" prop="sellType">
          <el-select v-model="form.sellType" placeholder="请选择供应类别">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="供应类别编码" prop="sellTypeCode">
          <el-input v-model="form.sellTypeCode" placeholder="请输入供应类别编码" />
        </el-form-item>
        <el-form-item label="供应种类" prop="sellClass">
          <el-input v-model="form.sellClass" placeholder="请输入供应种类" />
        </el-form-item>
        <el-form-item label="供应种类编码" prop="sellClassCode">
          <el-input v-model="form.sellClassCode" placeholder="请输入供应种类编码" />
        </el-form-item>-->
        <el-form-item label="审核状态" prop="isCheck">
          <el-select v-model="form.isCheck" placeholder="请选择"  :disabled="true">
            <el-option
              v-for="dict in checkStatus"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="供应标题" prop="sellTitle">
          <el-input v-model="form.sellTitle" placeholder="请输入供应标题" />
        </el-form-item>
        <el-form-item label="供应发布时间间隔" prop="sellPublishInterval">
          <el-select v-model="queryParams.sellPublishInterval" placeholder="供应发布时间间隔" clearable size="small">
            <el-option
              v-for="dict in intervalOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="发布时间" prop="createTime">
          <el-date-picker clearable size="small"
            v-model="form.createTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择发布时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="图片路径" prop="picAddress">
          <!--<el-input v-model="form.picAddress" placeholder="请输入图片路径" />-->
          <imageUpload v-model="form.picAddress" :limit="limit"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listSell, getSell, delSell, addSell, updateSell, exportSell } from "@/api/wuyi/sell";
import ImageUpload from '@/components/ImageUpload';
export default {
  name: "Sell",
  components: {ImageUpload},
  props: {},
  filters: {},
  data() {
    return {
      pid:0,
      provinceValue:'',
      cityValue:'',
      areaValue:'',
      level1Data:[],
      level2Data:[],
      level3Data:[],
      level1PID: 0,
      level2PID: 0,
      level3PID:0,
      errorimg:'this.src="'+require('../../../assets/logo/logo.png')+'"',
      showTitle:"地图显示",
      isShowDialog:false,
      locationInfo:{
        iocn:"",
        name:"清风",
        longitude:"117.121024 ", // 经度
        latitude:"36.654143", // 纬度
        address:"鹤壁" // 地址
      },
      // 上传图片数量限制
      limit: 1,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 日期范围
      dateRange: [],
      // 供应信息表格数据
      sellList: [],
      // 弹出层标题
      title: "",
      // 审核状态字典
      checkStatus: [],
      // 状态数据字典
      statusOptions: [],
      // 间隔数据字典
      intervalOptions: [],
      // 是否显示弹出层
      open: false,
      // 是否显示审核弹出层
      openCheck:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sellNum: null,
        sellName: null,
        sellTel: null,
        sellPhone: null,
        sellCompany: null,
        sellAddress: null,
        sellAmount: null,
        sellStartAmount: null,
        sellSize: null,
        sellProduct: null,
        sellProductPrice: null,
        sellMode: null,
        sellSupplyTime: null,
        sellTime: null,
        sellProvince: null,
        sellProvinceCode: null,
        sellCity: null,
        sellCityCode: null,
        sellCounty: null,
        sellCountyCode: null,
        sellType: null,
        sellTypeCode: null,
        sellClass: null,
        sellClassCode: null,
        sellTitle: null,
        isCheck: null,
        sellPublishInterval: null,
        createTime: null,
        picAddress: null,
        feedBack:null,
        isAsc:'desc',
        orderByColumn:'create_time'
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    const sellPhone = this.$route.params && this.$route.params.sellPhone;
    this.getSell(sellPhone);
    this.getList();
    this.getDicts("sell_type").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("interval_type").then(response => {
      this.intervalOptions = response.data;
    });
    this.getDicts("check_type").then(response => {
      this.checkStatus = response.data;
    });
    this.chusheng();
  },
  methods: {
    /** 根据手机号查询供应信息 */
    getSell(sellPhone) {
      this.queryParams.sellPhone = sellPhone;
      this.getList();
    },


    //这里是删除的时候清空所选中的Id
    shengdel() {
      console.log('删除省')
      this.level1PID = 0;
      this.level2PID = 0;
      this.level3PID = 0;
    },
    shidel() {
      console.log('删除市')
      this.level2PID = 0;
      this.level3PID = 0;
    },
    qudel() {
      this.level3PID = 0;
      console.log('删除区')
    },
    //下拉区请求区的数据
    chuxian() {
      getCategoryByPid(this.level2PID).then(response => {
        this.level3Data = response.data
      });
    },
    //下拉区请求区的数据下拉市请求市的数据
    chushi() {
      getCategoryByPid(this.level1PID).then(response => {
        this.level2Data = response.data
      });
    },
    //点击选择省下拉时调取的接口
    //具体情况根据自己公司后台提供的需求，我这里是分三次请求，下拉省请求省的数据，下拉市请求市的数据
    //下拉区请求区的数据
    chusheng() {
      getCategoryByPid(this.pid).then(response => {
        this.level1Data = response.data
      });
    },

    chooseProvince(value) {
      var that = this;
      that.form.sellType = '';
      this.form.sellClass = '';
      that.level2Data = [];
      that.level3Data = [];
      that.level1Data.forEach(e=>{//遍历数据
        if( value == e.name){
          //可输出e看看自己的数据字段名字是多少
          console.log(e)
          that.level1PID = e.id;
          return;
        }
      })
      console.log(this.sellType)
      this.chushi()
    },
    chooseCity(value) {
      var that = this;
      this.form.sellClass = '';
      that.level2Data.map(e=>{//遍历数据
        if( value == e.name){
          that.level3Data = e.areaList;
          console.log(e)
          that.level2PID = e.id;
          return;
        }
      })
      console.log(that.sellTypeCode)
      this.chuxian()
    },
    chooseArea(value) {
      var that = this;
      that.level3Data.map(e=>{//遍历数据
        if (value == e.name) {
          that.level3PID = e.id;
          console.log(e)
        }
      })
    },
    // 父组件获取数据
    getVal (result) {
      console.log(1000000000)
      console.log(result)
      this.form.longitude=result.lng
      this.form.latitude=result.lat
      this.form.sellAddress=result.address
      this.form.sellProvince=result.province
      this.form.sellCity=result.city
      this.form.sellCounty=result.district
    },
    showMpDialog(row){
      debugger
      console.log(row)
      console.log(row.longitude)
      console.log(row.sellAddress)
      this.isShowDialog=true;
      this.locationInfo ={
        /*iocn:row.snapshoot,
        name:row.name,*/
        longitude:row.longitude == undefined ? "116.411189" : row.longitude, // 经度   longitude:"117.121024 ", // 经度
        latitude:row.latitude == undefined ? "39.907957" : row.latitude, // 纬度  latitude:"36.654143", // 纬度
        address:row.sellAddress == undefined ? "北京市" : row.sellAddress
      }
    },
    /** 查询供应信息列表 */
    getList() {
      this.loading = true;
      listSell(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.sellList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 字典状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.sellNum);
    },
    intervalFormat(row, column) {
      return this.selectDictLabel(this.intervalOptions, row.sellPublishInterval);
    },
    checkFormat(row, column) {
      return this.selectDictLabel(this.checkStatus, row.isCheck);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.openCheck = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        sellNum: null,
        sellName: null,
        sellTel: null,
        sellPhone: null,
        sellCompany: null,
        sellAddress: null,
        sellAmount: null,
        sellStartAmount: null,
        sellSize: null,
        sellProduct: null,
        sellProductPrice: null,
        sellMode: null,
        sellSupplyTime: null,
        sellTime: null,
        sellProvince: null,
        sellProvinceCode: null,
        sellCity: null,
        sellCityCode: null,
        sellCounty: null,
        sellCountyCode: null,
        sellType: null,
        sellTypeCode: null,
        sellClass: null,
        sellClassCode: null,
        sellTitle: null,
        sellPublishInterval: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        feedBack: null,
        picAddress: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  /*  /!** 跳转地图 *!/
    gotolink() {
      this.$router.push({path:'/map/info'});
    },*/
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加供应信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSell(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改供应信息";
      });
    },
    /** 审核按钮操作 */
    handleCheck(row,flag) {
      this.reset();
      this.form.id=row.id;
      const id = row.id || this.ids;
      if(flag==1){
         this.form.isCheck = flag;
         updateSell(this.form).then(response => {
          this.msgSuccess("审核成功");
          this.open = false;
          this.getList();
        });
      }else {
        getSell(id).then(response => {
          this.form = response.data;
          this.openCheck = true;
          this.title = "填写审核信息";
        });
      }

    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateSell(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.openCheck = false;
              this.getList();
            });
          } else {
            addSell(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除供应信息编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delSell(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有供应信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportSell(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
